package app;

import app.server.NettyServer;
import com.keter.framework.core.config.AvoidScan;
import com.keter.framework.core.util.ConcurrentUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@AvoidScan
public class NettyMvcStart implements CommandLineRunner {

    @Autowired  NettyServer nettyServer;

//    @Autowired
//    void init(){
//        // 为了同时运行Servlet和Netty
//        ConcurrentUtil.service(1).submit(
//            () ->  nettyServer.start()
//        );
//    }

    public static void main(String[] args) {
        SpringApplication.run(NettyMvcStart.class, args);
    }

    @Override
    public void run(String... args) {
        // 为了同时运行Servlet和Netty
        ConcurrentUtil.service(1).submit(
                () ->  nettyServer.start()
        );
    }
}
